﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

namespace FileStreamsAndCrypto
{
    class MoveFiles
    {
        static void CopyAllFiles(string sourcePath, string destPath)
        {
            Directory.CreateDirectory(destPath);
            foreach (string strDirName
                 in Directory.GetDirectories(sourcePath, "*"))
            {
                string newSource = sourcePath + "\\" + strDirName.Substring(strDirName.LastIndexOf("\\"));
                string newDest = destPath + "\\" + strDirName.Substring(strDirName.LastIndexOf("\\"));
                Directory.CreateDirectory(newDest);
                CopyAllFiles(newSource, newDest);
            }
            CopyFilesFromDir(sourcePath, destPath);
        }
        
        static public void CopyFilesFromDir(string path, string dest)
        {
            foreach (string strFileName
                 in Directory.GetFiles(path, "*.*"))
            {
                File.Copy(strFileName, dest + strFileName.Substring(strFileName.LastIndexOf("\\")), true);
            }
        }

        //static void Main()
        //{
        //    string source = @"C:\Users\Academy\Desktop";
        //    string destination = @"C:\Users\Academy\Desktop\NEWFOLDER";
        //    CopyAllFiles(source, destination);
        //}
    }
}
